import { getReceiverTypeOptions } from '@/api/sms'
import { ref } from 'vue'

export default () => {
  // 获取接收者类型选项加载
  const getReceiverTypeOptionsLoading = ref(false)

  // 接收者类型选项
  const receiverTypeOptions = ref<Array<ReceiverTypeOptions>>([])

  /**
   * 获取接收者类型选项
   * @param {String} id - 短信模板id
   */
  const getReceiverTypeOptionsBySmsTemplateId = async (id: string) => {
    getReceiverTypeOptionsLoading.value = true
    const res = await getReceiverTypeOptions(id)
    getReceiverTypeOptionsLoading.value = false
    receiverTypeOptions.value = res.data.data.rows
  }

  return {
    receiverTypeOptions,
    getReceiverTypeOptionsLoading,
    getReceiverTypeOptionsBySmsTemplateId,
  }
}
